package com.example.yuekaoceshi.presenter;

import android.content.Context;

import com.example.yuekaoceshi.http.TypeApi;
import com.example.yuekaoceshi.moudle.Main_Moudle;
import com.example.yuekaoceshi.view.Main_view;

import java.util.Map;

/**
 * Created by 段傅华 on 2018/12/11.
 */

public class Presenter implements Main_Presenter, Main_Moudle.Finish {
    private Main_Moudle mMain_moudle;
    private Main_view mMain_view;

    public Presenter(Main_Moudle main_moudle, Main_view main_view) {
        mMain_moudle = main_moudle;
        mMain_view = main_view;
    }

    @Override
    public void getdata(String url, Map<String, Object> map, Context context, TypeApi typeApi) {
        if (mMain_view!=null){
            mMain_moudle.setdata(url,map,context,typeApi,this);
        }
    }

    @Override
    public void setData(Object o, TypeApi typeApi) {
        if (mMain_view!=null){
            mMain_view.showData(o,typeApi);
        }
    }

    @Override
    public void setError(String error) {
        if (mMain_view!=null){
            mMain_view.showError(error);
        }
    }
}
